package com.show.controller.show;

import com.show.model.Essay;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpSession;
import java.util.ArrayList;

@Controller
@Scope("prototype")
@RequestMapping("/show")
public class ShowController {

    /**
     * 访客访问首页，加载首页数据，页面跳转
     *
     * @return
     */
    @RequestMapping(value = "/index", method = RequestMethod.GET)

    public ModelAndView index(HttpSession session) {

//
//        // 新建返回值对象
        ModelAndView mv = new ModelAndView();
        mv.setViewName("/index");
//        session.setAttribute("kitWeb",webSetting);
        return mv;

    }


    /**
     * 访客访问首页，加载首页数据，页面跳转
     *
     * @return
     */
    @RequestMapping(value = "/enjoylife", method = RequestMethod.GET)
    //@ResponseBody
    public ModelAndView enjoylife(HttpSession session) {
        Essay essay = new Essay();
        ArrayList<Essay> essays = new ArrayList<>();

        // 新建返回值对象
        ModelAndView mv = new ModelAndView();
        mv.setViewName("/enjoylife");
//        session.setAttribute("kitWeb",webSetting);
        System.out.println("===================================================");
        return mv;


    }


}
//    再要输出日志的类中加入属性
//    private Logger log = Logger.getLogger(cc.openkit.admin.controller.admin.AdminController.class);
//
//    @Resource
//    private cc.openkit.admin.service.admin.AdminService adminService;
//    @Resource
//    private cc.openkit.admin.service.web.WebSettingService webSettingService;
//    @Resource
//    private cc.openkit.admin.service.g.GGroupLimitService gGroupLimitService;
//    @Resource
//    private cc.openkit.admin.service.g.GGroupService gGroupService;


/**
 * 用户后台登录页面跳转
 *
 * @return 登录验证方法
 * @param request
 * @param session
 * @return 登录验证方法
 * @param request
 * @param session
 * @return 登录验证方法
 * @param request
 * @param session
 * @return 登录验证方法
 * @param request
 * @param session
 * @return 登录验证方法
 * @param request
 * @param session
 * @return
 */
//    @RequestMapping(value = "/index", method = RequestMethod.GET)
//    @ResponseBody
//    public ModelAndView index(HttpSession session){
//        log.info("用户登录跳转方法");
//        log.debug("测试debug");
//        WebSetting webSetting = webSettingService.queryById(1);
//        // 新建返回值对象
//        ModelAndView mv = new ModelAndView();
//        mv.setViewName("/admin/login");
//        session.setAttribute("kitWeb",webSetting);
//        return mv;
//    }

/**
 * 登录验证方法
 * @param request
 * @param session
 * @return
 */
//    @RequestMapping(value = "/tologin", method = RequestMethod.POST)
//    @ResponseBody
//    public ModelAndView tologin(HttpServletRequest request, HttpSession session) {
//        log.info("开始登陆了");
//        // 新建返回值对象
//        ModelAndView mv = new ModelAndView();
//        // 取值
//        String username = request.getParameter("username");
//        String password = request.getParameter("password");
//
//        // 组装对象
//        Admin admin = new Admin();
//        admin.setKitAdminUsername(username);
//        admin.setKitAdminPassword(password);
//
//        // 查询
//        Admin returnAdmin = adminService.getModelByUsernameAndPassword(admin);
//        Admin returnAdmin1 = new Admin();
//        returnAdmin1 = returnAdmin;
//        // 判断
//        if (returnAdmin == null) {
//            // 如果为空，跳转到登录页面
//            mv.setViewName("/admin/login");
//            mv.addObject("msg", cc.openkit.admin.util.StaticFinalVar.USERNAME_OR_PWD_ERR);
//            return mv;
//        }
//    }
//
//
//}